﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using ClassLibrary.DAO;
using ClassLibrary.Data;
using System.Globalization;

public partial class Admin_UserControl_Report : System.Web.UI.UserControl
{
    TblJobsDAO JobsDAO = new TblJobsDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();      

        }
    }

    private void LoadData()
    {
        string id = Request.QueryString["id"];
        DataTable dt = JobsDAO.reportJob1(Convert.ToInt32(id));
        foreach (DataRow dr in dt.Rows)
        {
            lblBookInDate.Text = Convert.ToDateTime(dr["DateBook"].ToString()).ToString("dd/MM/yyyy");
            lblJobNo.Text = dr["JobID"].ToString();
            //lblBookBy.Text = "Michael Tran";
            string idBookBy = dr["BookByID"].ToString();
            if (idBookBy == "1")
            {
                lblBookBy.Text = "Michael";

            }
            if (idBookBy == "2")
            {
                lblBookBy.Text = "Thao";
            }
            if (idBookBy == "3")
            {
                lblBookBy.Text = "Tung";
            }
            if (idBookBy == "4")
            {
                lblBookBy.Text = "Mi";
            }
            lblJobType.Text = dr["JobType"].ToString();

            lblCusID.Text = dr["CustomerIndex"].ToString();
           // lblCusName.Text = dr["CustomerFirstname"].ToString() +" " + dr["CustomerLastname"].ToString();
            lblCusName.Text = dr["CustomerFullname"].ToString();
            lblCompany.Text = dr["Companyname"].ToString();
            lblMobiPhone.Text = dr["phonemobile"].ToString();
            lblEmail.Text = dr["emailaddress"].ToString();
            lblHomePhone.Text = dr["phonehome"].ToString();
            lblWordPhone.Text = dr["phonework"].ToString();
            int pre = Convert.ToInt32(dr["PreferContactMethod"]);
            if (pre == 1)
            { lblPreContact.Text = "Mobile"; }
            if (pre == 2)
            { lblPreContact.Text = "Email"; }
            if (pre == 3)
            { lblPreContact.Text = "Home"; }
            if (pre == 4)
            { lblPreContact.Text = "work"; }
            else if(pre == 0)
            { lblPreContact.Text = ""; }

            lblManuFactuer.Text = dr["Manufacturer"].ToString();
            lblModel.Text = dr["Model"].ToString();
            lblIMEI.Text = dr["IMEINo"].ToString();
            lblAccssories.Text = dr["AccessoriesWithPhone"].ToString();
            lblFauls.Text = dr["FaultDescription"].ToString();
            lblOther.Text = dr["OrtheInstructions"].ToString();

            //lblCondition.Text = dr["PhoneCondition"].ToString();
            int condition = Convert.ToInt32(dr["PhoneCondition"].ToString());
            if (condition == 1)
            {
                lblCondition.Text = "Poor";
            }
            if (condition == 2)
            {
                lblCondition.Text = "Fair";
            }
            if (condition == 3)
            {
                lblCondition.Text = "Good";
            }
            lblLphoneID.Text = dr["LPhoneID"].ToString();
            lblRManufacture.Text = dr["LBrand"].ToString();
            lblRAccessrories.Text = "";
            lblRModel.Text = dr["lModel"].ToString();
           
            lblRTotal.Text = "";
            lblRIMEI.Text = dr["lIMENo"].ToString();
            //lblDeposit.Text = "";


            if (dr["AmountQuoted"].ToString() == "")
            {
                lblAmount.Text = "$0.00";
            }
            else
            {
                lblAmount.Text = decimal.Parse(dr["AmountQuoted"].ToString()).ToString("c");
            }

            if (dr["LoanFee"].ToString() == "")
            {
                lblRLoanFee.Text = "$0.00";
            }
            else
            {
                lblRLoanFee.Text = decimal.Parse(dr["LoanFee"].ToString()).ToString("c");
            }
            if (dr["AmountDeposited"].ToString() == "")
            {
                lblDeposit.Text = "$0.00";
            }
            else
            {
                lblDeposit.Text = decimal.Parse(dr["AmountDeposited"].ToString()).ToString("c");
            }

        }
    }
}
